local skynet = require "skynet"
local mysql_tool = {}
local cluster = require "skynet.cluster"

function mysql_tool:call_pr(callStr)
    log.info("mysql_tool callstr= ", callStr)
    local ok, res = cluster.call("mysql", ".mysql", "Call", callStr)
    --log.info("mysql_tool res=", res)
    return ok, res
end

function mysql_tool.call_pr2(str)
    local ok, ret = mysql_tool.query(str)
    --[[
        ret 的结构是 {
            [1] = {       --第1个select结果集
                [1] = {},[2] = {}
            },
            [2] = ...,    --第2个select结果集
            ...,          --第n个select结果集
            [n + 1] = {
                server_status = ...
                affected_rows = ...
            },
            mulitresultset = true
        }
    ]]
    if ok and ret then
        return true, ret     --这个结果还是一个数组
    else
        skynet.error('call_pr failed, str:', str)
    end

    return false, {}
end

return mysql_tool